<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <script>
        window.addEventListener('load',function(){
            // 找到按钮
            var btn=document.querySelector('button');
            btn.addEventListener('click',function(){
                btn.disabled=true;
                //  btn.innerHTML = '还剩'+ time +'秒';
                // 定义多久后按钮可以在点
                var time=5;
                btn.innerHTML = '还剩'+ time +'秒';
                time--;
                var timer=setInterval(function(){
                    if(time != 0){
                        btn.innerHTML = '还剩'+ time +'秒';
                        time--;
                    }else{
                        // 清除这个定时器  并且让按钮复位
                        clearInterval(timer);
                        btn.disabled=false;
                        btn.innerHTML='发送'
                    }
                },1000);
            });
        });

    </script>

    <button>发送</button>

    
</body>
</html>